package com.sangananitsolution.fragments;

import java.util.ArrayList;

import android.app.Activity;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.view.View;

import com.sangananitsolution.database.FavouirteItemCRUD;
import com.sangananitsolution.gogoproject.R;

public class MainBackgroundFragment extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.mainbackgroundfragment);

		android.app.FragmentManager fragmentManager = getFragmentManager();
		android.app.FragmentTransaction fragmentTransaction = fragmentManager
				.beginTransaction();

		fragmentTransaction
				.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);

		fragmentTransaction.addToBackStack(null);
		fragmentTransaction.replace(R.id.mainfragmentlayout, new MyHomePage());
		fragmentTransaction.commit();

	}

	Mysearch_SearchOption mysearchLoctionandItem = new Mysearch_SearchOption();

	@Override
	public void onBackPressed() {
		if (mysearchLoctionandItem.isVisible())
			mysearchLoctionandItem.onBackPressed();
		else
			super.onBackPressed();
	}

	public void mySearch(View view) {

		android.app.FragmentManager fragmentManager = getFragmentManager();
		android.app.FragmentTransaction fragmentTransaction = fragmentManager
				.beginTransaction();

		fragmentTransaction
				.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);

		fragmentTransaction.addToBackStack(null);
		fragmentTransaction.replace(R.id.mainfragmentlayout, new MySearch());
		fragmentTransaction.commit();

	}

	public void mygarbageSale(View view) {
		android.app.FragmentManager fragmentManager = getFragmentManager();
		android.app.FragmentTransaction fragmentTransaction = fragmentManager
				.beginTransaction();

		fragmentTransaction
				.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);

		fragmentTransaction.addToBackStack(null);
		fragmentTransaction.replace(R.id.mainfragmentlayout,
				new MygarbageSale());
		fragmentTransaction.commit();

	}

	public void myfavouirte(View view) {

		FavouirteItemCRUD favouirteItemCRUD = new FavouirteItemCRUD(
				getApplicationContext());

		ArrayList<String> productimage = favouirteItemCRUD.getProductImage();
		ArrayList<String> GarageSaleTitle = favouirteItemCRUD
				.getGarageSaleTitle();
		ArrayList<String> StartDate = favouirteItemCRUD.getStartDate();
		ArrayList<String> OneOrTwoDaySale = favouirteItemCRUD
				.getOneOrTwoDaySale();
		ArrayList<String> SaleStartTime = favouirteItemCRUD.getSaleStartTime();
		ArrayList<String> SaleFinishTime = favouirteItemCRUD
				.getSaleFinishTime();
		ArrayList<String> UnitStreeNo = favouirteItemCRUD.getUnitStreeNo();
		ArrayList<String> StreeName = favouirteItemCRUD.getStreeName();
		ArrayList<String> Suburb = favouirteItemCRUD.getSuburb();
		ArrayList<String> City = favouirteItemCRUD.getCity();
		ArrayList<String> State = favouirteItemCRUD.getState();
		ArrayList<String> PostCode = favouirteItemCRUD.getPostCode();
		ArrayList<String> Description = favouirteItemCRUD.getDescription();
		ArrayList<String> EarlyBirdMessage = favouirteItemCRUD
				.getEarlyBirdMessage();
		ArrayList<String> BadWeatherMessage = favouirteItemCRUD
				.getBadWeatherMessage();
		ArrayList<String> GoodsType = favouirteItemCRUD.getGoodsType();
		ArrayList<String> CurrentUser = favouirteItemCRUD.getCurrentUser();
		ArrayList<String> Longitude = favouirteItemCRUD.getLongitude();
		ArrayList<String> Latitude = favouirteItemCRUD.getLatitude();
		ArrayList<String> ProductID = favouirteItemCRUD.getProductID();

		android.app.FragmentManager fragmentManager = getFragmentManager();
		android.app.FragmentTransaction fragmentTransaction = fragmentManager
				.beginTransaction();

		fragmentTransaction
				.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);

		fragmentTransaction.addToBackStack(null);
		fragmentTransaction.replace(R.id.mainfragmentlayout,
				new MySearch_SearchOption_OnSubmit(getApplicationContext(), Description,
						Suburb, productimage, StartDate, SaleStartTime,
						SaleFinishTime, ProductID, GarageSaleTitle,
						OneOrTwoDaySale, UnitStreeNo, StreeName, City, State,
						PostCode, EarlyBirdMessage, BadWeatherMessage,
						GoodsType, CurrentUser, Longitude, Latitude));
		fragmentTransaction.commit();

	}

	public void myhome(View view) {

		android.app.FragmentManager fragmentManager = getFragmentManager();
		android.app.FragmentTransaction fragmentTransaction = fragmentManager
				.beginTransaction();

		fragmentTransaction
				.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);

		fragmentTransaction.addToBackStack(null);
		fragmentTransaction.replace(R.id.mainfragmentlayout, new MyHomePage());
		fragmentTransaction.commit();

	}

}
